package com.wyl.selenium.framework;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Date;

/**
 * @Description
 * @Author WuYiLong
 * @Date 2023/11/17 14:41
 */
public class BaseServiceImpl<T extends BaseEntity<T>> extends ServiceImpl<BaseMapper<T>,T> implements BaseService<T>{

    @Override
    public void saveEntity(T t) {
        if(t instanceof BaseEntity) {
            if(t.getId() != null) {
                t.setUpdateTime(new Date());
            }else{
                t.setCreateTime(new Date());
                t.setUpdateTime(new Date());
                t.setDeleted(0);
            }
            saveOrUpdate(t);
        }
    }

    @Override
    public void beforeSaveEntity(T t) {

    }

    @Override
    public void afterSaveEntity(T t) {

    }


}
